const { menuList } = require('./src/mock')
const bodyParser = require('body-parser')
console.log(menuList);
module.exports = {
	devServer: {
		before(app) {
			// 处理 json
			app.use(bodyParser.json())

			app.get('/api/menu/list', (req, res) => {
				res.send({
					code: 200,
					data: menuList
				})
			})


			app.post('/api/detail', (req, res) => {
				const { id } = req.body;
				console.log(id);

				menuList.forEach(v => {
					v.subMenuList.forEach(v => {
						if (v.id === id) {
							res.send({
								code: 200,
								data: v
							})
						}
					})
				})

			})
		}
	}
}